﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        FillDataToGridView();       
    }

    private void FillDataToGridView() {
        //Disconnected UnType
        //FillByUnType();

        //Disconnected Type
        FillByType();
    }
    void FillByUnType() {
        GridView1.DataSource = ProductDAO.GetAllProducts();
        GridView1.DataBind();
    }
    void FillByType() {
        GridView1.DataSource = ProductDAO.GetAllProductsType();
        GridView1.DataBind();
    }
    
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        //Disconnected UnType
        //SearchByUnType();

        //Disconnected Type
        SearchByType();
    }

    void SearchByUnType() {
        GridView1.DataSource = ProductDAO.GetProductByID(txtSearch.Text);
        GridView1.DataBind();
    }
    void SearchByType() {
        GridView1.DataSource = ProductDAO.GetProductByNameType(txtSearch.Text);
        GridView1.DataBind();
    }

}